package com.app.shop.controller.wx;

import com.app.shop.controller.system.BaseController;
import com.app.shop.entity.show.WxModel;
import com.app.shop.entity.show.WxProductModel;
import com.app.shop.entity.show.WxProductOrderModel;
import com.app.shop.util.ApiRest;
import com.app.shop.util.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;


/**
 * 产品模块
 *
 * @author chenliwei
 * @version v1.0 2017-11-5
 */
@Controller
@RequestMapping(value = "/api/product")
public class WxProductController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(WxProductController.class);

    /**
     * 产品详情
     * @param proId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/productById")
    public ApiRest getProductById(Integer proId) {

        WxProductModel wxProductModel=new WxProductModel();
        wxProductModel.setProId(1001);
        wxProductModel.setName("健身产品");
        List<String> list1=new ArrayList<>();
        list1.add("减肥健身");
        list1.add("减肥健身");
        list1.add("减肥健身");
        wxProductModel.setShowList(list1);
        List<String> list2=new ArrayList<>();
        list2.add("http://127.0.0.1:9999/static/image/banner1.jpg");
        list2.add("http://127.0.0.1:9999/static/image/banner1.jpg");
        list2.add("http://127.0.0.1:9999/static/image/banner1.jpg");
        wxProductModel.setImgList(list2);
        wxProductModel.setSaleCnt(200);
        wxProductModel.setPrice(Double.valueOf(299));
        wxProductModel.setStockCnt(600);
        wxProductModel.setLookCnt(1000);
        wxProductModel.setPriceOld(Double.valueOf(699));
        wxProductModel.setDesc("<div style=\"width:100%\">\n" +
                "\t\t\t\t\t\t<img style=\"width:100%;display:block;\" src=\"https://gd3.alicdn.com/imgextra/i4/479184430/O1CN01nCpuLc1iaz4bcSN17_!!479184430.jpg_400x400.jpg\" />\n" +
                "\t\t\t\t\t\t<img style=\"width:100%;display:block;\" src=\"https://gd2.alicdn.com/imgextra/i2/479184430/O1CN01gwbN931iaz4TzqzmG_!!479184430.jpg_400x400.jpg\" />\n" +
                "\t\t\t\t\t\t<img style=\"width:100%;display:block;\" src=\"https://gd3.alicdn.com/imgextra/i3/479184430/O1CN018wVjQh1iaz4aupv1A_!!479184430.jpg_400x400.jpg\" />\n" +
                "\t\t\t\t\t\t<img style=\"width:100%;display:block;\" src=\"https://gd4.alicdn.com/imgextra/i4/479184430/O1CN01tWg4Us1iaz4auqelt_!!479184430.jpg_400x400.jpg\" />\n" +
                "\t\t\t\t\t\t<img style=\"width:100%;display:block;\" src=\"https://gd1.alicdn.com/imgextra/i1/479184430/O1CN01Tnm1rU1iaz4aVKcwP_!!479184430.jpg_400x400.jpg\" />\n" +
                "\t\t\t\t\t</div>");

        return new ApiRest(Constant.REST_SUCCESS_CODE, Constant.SUCCESS_MESSAGE, wxProductModel);
    }


    /**
     * 订单产品详情
     * @param proId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/productOrderById")
    public ApiRest getProductOrder(Integer proId) {

        WxProductOrderModel wxProductModel=new WxProductOrderModel();
        wxProductModel.setProId(1001);
        wxProductModel.setName("健身产品");
        wxProductModel.setShowStr("减肥健身,减肥健身,减肥健身");
        wxProductModel.setPrice(Double.valueOf(299));
        wxProductModel.setProImage("http://127.0.0.1:9999/static/image/banner1.jpg");
        wxProductModel.setMaxNum(5);
        wxProductModel.setPriceOld(Double.valueOf(699));
        return new ApiRest(Constant.REST_SUCCESS_CODE, Constant.SUCCESS_MESSAGE, wxProductModel);
    }
}